ROOT = $(shell pwd)
INSTALL = $(ROOT)/install

# sdk
SYSROOT = $(ROOT)/sysroot
LLVM = $(ROOT)/llvm

# compile
CLANG = $(LLVM)/bin/clang
CLANGXX = $(LLVM)/bin/clang++
AR = $(LLVM)/bin/llvm-ar
AS = $(LLVM)/bin/llvm-as
NM = $(LLVM)/bin/llvm-nm
RANLIB = $(LLVM)/bin/llvm-ranlib
STRIP = $(LLVM)/bin/llvm-strip
OBJDUMP = $(LLVM)/bin/llvm-objdump
LD = $(LLVM)/bin/ld.lld

# cflags
OHOS_CFLAGS = --target=aarch64-linux-ohos --sysroot=$(SYSROOT)
OHOS_CFLAGS += -I$(SYSROOT)/usr/include/aarch64-linux-ohos
OHOS_CFLAGS += -L$(SYSROOT)/usr/lib/aarch64-linux-ohos
OHOS_CFLAGS += -I$(LLVM)/include
OHOS_CFLAGS += -L$(LLVM)/lib

ffmpeg:
	@mkdir -p $(INSTALL) && \
	tar -xzf $(ROOT)/FFmpeg-n7.1.1.tar.gz -C $(INSTALL) && \
	cd $(INSTALL)/FFmpeg-n7.1.1 && \
	./configure \
		--prefix=$(INSTALL) \
		--arch=aarch64 \
		--target-os=linux \
	    --disable-decoders \
        --enable-decoder=mp3 \
        --enable-decoder=aac \
        --enable-decoder=flac \
		--disable-programs \
		--disable-avdevice \
		--disable-swscale \
		--disable-avfilter \
		--disable-vulkan \
		--enable-neon \
		--enable-asm \
		--enable-cross-compile \
		--enable-small \
	    --disable-shared \
		--cc=$(CLANG) \
		--ld=$(CLANG) \
		--strip=$(STRIP) \
		--extra-cflags="$(OHOS_CFLAGS) $(OHOS_INCS) $(OHOS_LIBS)" \
		--extra-ldflags="$(OHOS_CFLAGS) $(OHOS_INCS) $(OHOS_LIBS)" && \
	make -j4 && make install && \
	cd - && \
	rm -rf $(INSTALL)/FFmpeg-n7.1.1
